package transcoding

import (
	"gitee.com/mootok/mootok/src/constant/config"
	"gitee.com/mootok/mootok/src/utils/logging"
	"github.com/qiniu/go-sdk/v7/auth/qbox"
)

var Instance Service

type Status int
const (
	StatusWaiting Status = iota
	StatusDoing
	StatusFailed
	StatusFinished
)

func init() {
	if config.EnvConfig.CensorServiceProvider == "qiniu" {
		Instance = &QiniuService{
			mac: qbox.NewMac(config.EnvConfig.QiNiuAccessKey, config.EnvConfig.QiNiuSecretKey),
		}
	} else if config.EnvConfig.SmsServiceProvider == "dummy" {
		Instance = &DummyService{}
	} else {
		logging.Logger.Warningf("Unknown transcoding provider \"%s\", use dummy instead.", config.EnvConfig.SmsServiceProvider)
		Instance = &DummyService{}
	}
}

type Service interface {
	CreateTranscodingTask(fileName string, params string) (string, error)
	QueryTranscodingProgress(jobId string) (status Status, err error)
}